import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from sklearn import datasets
from sklearn.decomposition import PCA

iris = datasets.load_iris()
X = iris.data
y = iris.target

fig = plt.figure(1, figsize=(8, 6))
ax = fig.add_subplot(111, projection='3d') 
X_reduced = PCA(n_components=3).fit_transform(X)
ax.scatter(X_reduced[:, 0], X_reduced[:, 1], X_reduced[:, 2], c=y)
ax.set_title("First three PCA directions")
ax.set_xlabel("1st eigenvector")
ax.set_xticklabels([])  
ax.set_ylabel("2nd eigenvector")
ax.set_yticklabels([]) 
ax.set_zlabel("3rd eigenvector")
ax.set_zticklabels([])  

plt.show()